﻿<Window x:Class="Black.CameraCapture.Client.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:controls="clr-namespace:Black.CameraCapture;assembly=Black.CameraCapture"
        xmlns:local="clr-namespace:Black.CameraCapture.Client"
        Title="Black Camera Capture - Client"
        MinWidth="500"
        MinHeight="500"
        Closing="OnClosing"
        SizeToContent="WidthAndHeight">

    <!--  Ressources  -->

    <Window.Resources>
        <local:BoolInvertionConverter x:Key="BoolInvertionConverter" />
    </Window.Resources>

    <!--  Root de la fenêtre  -->

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <!--  Sélection device  -->

        <TextBlock Grid.Row="0"
                   Grid.Column="0"
                   Margin="10"
                   Text="Device :" />

        <ComboBox x:Name="SelectDevice"
                  Grid.Row="0"
                  Grid.Column="1"
                  Margin="10"
                  ItemsSource="{Binding ElementName=Camera,
                                        Path=Devices}">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Name}" />
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>

        <!--  Sélection display  -->

        <TextBlock Grid.Row="1"
                   Grid.Column="0"
                   Margin="10"
                   Text="Display :" />

        <ComboBox x:Name="SelectDisplay"
                  Grid.Row="1"
                  Grid.Column="1"
                  Margin="10"
                  ItemsSource="{Binding ElementName=Camera,
                                        Path=Displays}"
                  SelectedItem="{Binding ElementName=Camera,
                                         Path=CurrentDisplay,
                                         Mode=TwoWay}">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Name}" />
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>

        <!--  Contrôle de visionnage  -->

        <controls:CameraCaptureControl x:Name="Camera"
                                       Grid.Row="2"
                                       Grid.Column="0"
                                       Grid.ColumnSpan="2"
                                       Margin="10"
                                       HorizontalAlignment="Center"
                                       VerticalAlignment="Center"
                                       CurrentDevice="{Binding ElementName=SelectDevice,
                                                               Path=SelectedItem}"
                                       CurrentDisplay="{Binding ElementName=SelectDisplay,
                                                                Path=SelectedItem}" />

        <!--  Boutons d'action  -->

        <StackPanel Grid.Row="3"
                    Grid.Column="0"
                    Grid.ColumnSpan="2"
                    Margin="10"
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    Orientation="Horizontal">

            <Button Width="120"
                    Height="40"
                    Click="OnStartClick"
                    Content="Start"
                    IsEnabled="{Binding ElementName=Camera,
                                        Path=IsStarted,
                                        Converter={StaticResource BoolInvertionConverter}}" />

            <Button Width="120"
                    Height="40"
                    Margin="20,0,0,0"
                    Click="OnStopClick"
                    Content="Stop" />

            <Button Width="120"
                    Height="40"
                    Margin="20,0,0,0"
                    Click="OnScreenshotClick"
                    Content="Screenshot" />
        </StackPanel>

        <!--  Screenshot  -->

        <Image x:Name="Screenshot"
               Grid.Row="0"
               Grid.RowSpan="4"
               Grid.Column="2"
               Margin="10"
               HorizontalAlignment="Center"
               VerticalAlignment="Center"
               Stretch="None" />

    </Grid>
</Window>
